package org.lib.data.user.service.impl;

import org.lib.data.user.api.dto.AddUserDTO;
import org.lib.data.user.entity.User;
import org.lib.data.user.repo.UserDAO;
import org.lib.data.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import lombok.extern.slf4j.Slf4j;

/**
 * 用户接口实现类：MySQL
 * @author ben
 * @date 2021-08-30 21:59:53 CST
 */
@Service
@Slf4j
public class UserServiceImpl implements UserService {

	@Autowired
	private UserDAO userDao;
	
	@Override
	public Long addUser(AddUserDTO dto) {
		User nuser = new User(dto.getName(), dto.getSex(), dto.getAge());
		User savedUser = userDao.save(nuser);
		log.info("添加用户成功：id={}", savedUser.getId());
		return savedUser.getId();
	}

}
